home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 7.4 KB | 305 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: BoundShp.cpp
- // Release Version: $ 1.0d11 $
- //
- // Author: Henri Lamiraux
- //
- // Copyright: © 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "ODFDraw.hpp"
-
- #ifndef BASESHP_H
- #include "BaseShp.h"
- #endif
-
- #ifndef BOUNDSHP_H
- #include "BoundShp.h"
- #endif
-
- #ifndef UTILS_H
- #include "Utils.h"
- #endif
-
- #ifndef CONSTANT_H
- #include "Constant.h"
- #endif
-
- #ifndef DRAWPART_H
- #include "DrawPart.h"
- #endif
-
- #ifndef DRAWPART_H
- #include "DrawPart.h"
- #endif
-
- #ifndef DRAWFRM_H
- #include "DrawFrm.h"
- #endif
-
- #ifndef DRAWPRXY_H
- #include "DrawPrxy.h"
- #endif
-
- #ifndef DRAWLINK_H
- #include "DrawLink.h"
- #endif
-
- #ifndef DRAWCLIP_H
- #include "DrawClip.h"
- #endif
-
- // ----- Part Layer -----
-
- #ifndef FWFRMING_H
- #include "FWFrming.h"
- #endif
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWSELECT_H
- #include "FWSelect.h"
- #endif
-
- #ifndef FWITERS_H
- #include "FWIters.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h"
- #endif
-
- #ifndef FWTXTBOX_H
- #include "FWTxtBox.h"
- #endif
-
- #ifndef FWLINSHP_H
- #include "FWLinShp.h"
- #endif
-
- #ifndef FWOVLSHP_H
- #include "FWOvlShp.h"
- #endif
-
- #ifndef FWRRCSHP_H
- #include "FWRRcShp.h"
- #endif
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODTransform_xh
- #include <Trnsform.xh>
- #endif
-
- //========================================================================================
- // Runtime Information
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfdrawshapes
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- FW_DEFINE_CLASS_M1(CBoundedShape, CBaseShape)
-
- //========================================================================================
- // class CBoundedShape
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CBoundedShape::CBoundedShape
- //----------------------------------------------------------------------------------------
-
- CBoundedShape::CBoundedShape(unsigned short shapeType, unsigned short renderVerb) :
- CBaseShape(4, shapeType, renderVerb)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CBoundedShape::CBoundedShape
- //----------------------------------------------------------------------------------------
-
- CBoundedShape::CBoundedShape(FW_CReadableStream& archive) :
- CBaseShape(archive)
- {
- archive >> fRect;
- }
-
- //----------------------------------------------------------------------------------------
- // CBoundedShape::~CBoundedShape
- //----------------------------------------------------------------------------------------
-
- CBoundedShape::~CBoundedShape()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // CBoundedShape::GetHandleCenter
- //----------------------------------------------------------------------------------------
-
- void CBoundedShape::GetHandleCenter(short whichHandle, FW_CPoint& center) const
- {
- switch (whichHandle)
- {
- case kInTopLeftCorner:
- center.x = fRect.left;
- center.y = fRect.top;
- break;
- case kInTopRightCorner:
- center.x = fRect.right;
- center.y = fRect.top;
- break;
- case kInBottomLeftCorner:
- center.x = fRect.left;
- center.y = fRect.bottom;
- break;
- case kInBottomRightCorner:
- center.x = fRect.right;
- center.y = fRect.bottom;
- break;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CBoundedShape::ResizeFeedback
- //----------------------------------------------------------------------------------------
-
- void CBoundedShape::ResizeFeedback(FW_CGraphicContext& gc, const FW_PInk& ink, const FW_PStyle& style,
- short whichHandle, const FW_CPoint& mouseLoc)
- {
- FW_CRect srcRect, dstRect;
- GetMapRects(whichHandle, mouseLoc, srcRect, dstRect);
- dstRect.Sort();
- OutlineShape(gc, ink, style, dstRect);
- }
-
- //----------------------------------------------------------------------------------------
- // CBoundedShape::GetMapRects
- //----------------------------------------------------------------------------------------
-
- void CBoundedShape::GetMapRects(short whichHandle, const FW_CPoint& mouseLoc,
- FW_CRect& srcRect, FW_CRect& dstRect)
- {
- srcRect = fRect;
- dstRect = srcRect;
-
- switch (whichHandle)
- {
- case kInTopLeftCorner:
- dstRect.left = mouseLoc.x;
- dstRect.top = mouseLoc.y;
- break;
- case kInTopRightCorner:
- dstRect.right = mouseLoc.x;
- dstRect.top = mouseLoc.y;
- break;
- case kInBottomLeftCorner:
- dstRect.left = mouseLoc.x;
- dstRect.bottom = mouseLoc.y;
- break;
- case kInBottomRightCorner:
- dstRect.right = mouseLoc.x;
- dstRect.bottom = mouseLoc.y;
- break;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CBoundedShape::MapShape
- //----------------------------------------------------------------------------------------
-
- void CBoundedShape::MapShape(Environment *ev, CDrawPart* part, const FW_CRect& srcRect, const FW_CRect& dstRect)
- {
- CheckPromise(ev, part);
-
- ClearCache();
-
- fRect.Map(srcRect, dstRect);
- fRect.Sort();
- }
-
- //----------------------------------------------------------------------------------------
- // CBoundedShape::OffsetShape
- //----------------------------------------------------------------------------------------
-
- void CBoundedShape::OffsetShape(Environment *ev, FW_CFixed xDelta, FW_CFixed yDelta)
- {
- ClearCache();
- fRect.Offset(xDelta, yDelta);
- }
-
- //----------------------------------------------------------------------------------------
- // CBoundedShape::SetShapeGeometry
- //----------------------------------------------------------------------------------------
-
- void CBoundedShape::SetShapeGeometry(const FW_CPoint& anchorPoint, const FW_CPoint& currentPoint)
- {
- if (anchorPoint.x < currentPoint.x)
- {
- fRect.left = anchorPoint.x;
- fRect.right = currentPoint.x;
- }
- else
- {
- fRect.left = currentPoint.x;
- fRect.right = anchorPoint.x;
- }
-
- if (anchorPoint.y < currentPoint.y)
- {
- fRect.top = anchorPoint.y;
- fRect.bottom = currentPoint.y;
- }
- else
- {
- fRect.top = currentPoint.y;
- fRect.bottom = anchorPoint.y;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CBoundedShape::Flatten
- //----------------------------------------------------------------------------------------
-
- void CBoundedShape::Flatten(FW_CWritableStream& archive)
- {
- CBaseShape::Flatten(archive);
- archive << fRect;
- }
-
- //----------------------------------------------------------------------------------------
- // CBoundedShape::SetRectGeometry
- //----------------------------------------------------------------------------------------
-
- void CBoundedShape::SetRectGeometry(const FW_CRect& bounds)
- {
- fRect = bounds;
- }
-
- //----------------------------------------------------------------------------------------
- // CBoundedShape::GetRectGeometry
- //----------------------------------------------------------------------------------------
-
- void CBoundedShape::GetRectGeometry(FW_CRect& bounds) const
- {
- bounds = fRect;
- }
-
-